#ifndef RAY_H
#define RAY_H
// To use, declare:
// - Object array with MAX_OBJECTS number of objects, and pass that in as a scene to CheckCollisions() CastRay()
// - CastRay() returns a color for saving

#include "raytypes.h"
//#include "vector.h"		// need Vector3 definition (but already included)

extern const int MAX_OBJECTS;		// externs.h needs Color and Object, declared below

// core
float CheckCollisions (Object *scene, Vector3 start, Vector3 unitVector, int ignore, bool ignoreLights, float hitBreak, Vector3 normal, int *hitOut);
Color CastRay (Object *scene, Vector3 start, Vector3 unitVector, int bounces);

// intersection functions
float IntersectSphereWS (Sphere sphere, Vector3 start, Vector3 unitVector, Vector3 normal);
float IntersectPlaneWS (Plane plane, Vector3 start, Vector3 unitVector, Vector3 normal);
float IntersectBboxWS(Box box, Vector3 start, Vector3 unitVector, Vector3 normal);
float IntersectDiscWS(Disc disc, Vector3 start, Vector3 unitVector, Vector3 normal);

float IntersectSphere (Sphere sphere, Vector3 start, Vector3 unitVector, Vector3 normal);
float IntersectBbox(Box box, Vector3 rayorigOS, Vector3 raydirOS, Vector3 surfnOS);
// no IntersectDisc or IntersectPlane

int GetFreeObject (Object *scene);		// Use with Object arrays
Object *AddSphere(Object *scene, Vector3 origin, float radius, Color color);
Object *AddBox (Object *scene, Vector3 origin, float x, float y, float z, Color color);
Object *AddPlane (Object *scene, Vector3 normal, float dist, Color color);
Object *AddDisc(Object *scene, Vector3 normal, Vector3 origin, float radius, Color color);
Object *AddLight(Object *scene, Vector3 origin, float radius, Color color);

#endif // RAY_H
